<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

<f:view>
<f:loadBundle var="text" basename="#{userList.bundleName}"/>
<head>
    <title>#{text['userList.title']}</title>
    <meta name="heading" content="#{text['userList.heading']}"/>
    <meta name="menu" content="AdminMenu"/>
</head>

<h:outputText value="#{text['userList.explain.message']}" />
<h:outputText value="#{text['userList.nousers']}" rendered="#{empty userList.users}"/>

<div id="search">
<h:form id="searchForm">
    <h:inputText id="q" name="q" size="20" value="#{userList.query}"/>
    <h:commandButton value="#{text['button.search']}" action="#{userList.search}" styleClass="button_small"/>
</h:form>
</div>

<h:form id="editUser">

<span class="buttongroup">
<h:commandButton value="#{text['button.add']}" action="#{userForm.add}" id="add" styleClass="button_small">
    <f:param name="from" value="list"/>
</h:commandButton>
<h:commandButton value="#{text['button.done']}" action="mainMenu" id="cancel"
    immediate="true" styleClass="button_small" />
</span>

<!-- Error from this table is caused by http://issues.apache.org/jira/browse/TOMAHAWK-466 -->
<div class="tests_background">
<t:dataTable id="users" var="user" 
    value="#{userList.users}" rows="10" sortColumn="#{userList.sortColumn}"
    sortAscending="#{userList.ascending}" styleClass="mainTable"
    headerClass="standardTable_Header" rowClasses="rowA,rowB"
    sortable="true">
    <t:column width="25%">
        <f:facet name="header">
            <t:commandSortHeader columnName="username" arrow="true">
                <h:outputText value="#{text['user.username']}" />
            </t:commandSortHeader>
        </f:facet>
		<h:outputText value="#{user.username}" />
    </t:column>
    <t:column width="34%">
        <f:facet name="header">
            <t:commandSortHeader columnName="fullName" arrow="true">
                <h:outputText value="#{text['activeUsers.fullName']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:outputText value="#{user.fullName}" />
    </t:column>
    <t:column width="25%">
        <f:facet name="header">
            <t:commandSortHeader columnName="email" arrow="true">
                <h:outputText value="#{text['user.email']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:outputLink value="mailto:#{user.email}">
            <h:outputText value="#{user.email}" />
        </h:outputLink>
    </t:column>
    <t:column >
        <f:facet name="header">
            <t:commandSortHeader columnName="enabled" arrow="true">
                <h:outputText value="#{text['user.enabled']}" />
            </t:commandSortHeader>
        </f:facet>
        <h:selectBooleanCheckbox value="#{user.enabled}" disabled="true"/>
    </t:column>
    <t:column>
        <f:facet name="header">
            <t:commandSortHeader columnName="review" arrow="true">
                <h:outputText value=" " />
            </t:commandSortHeader>
        </f:facet>
		<h:panelGroup layout="block">
			<h:commandButton action="#{userForm.initUser}" value="Manage" styleClass="button_inline" >
				<f:param name="id" value="#{user.id}"/>
				<f:param name="from" value="list"/> 
			</h:commandButton>
		</h:panelGroup>
    </t:column>
</t:dataTable>



<ui:include src="/common/tableFooter.xhtml">
    <ui:param name="tableName" value="users"/> 
</ui:include>

</div>

<script type="text/javascript">
    highlightTableRows("editUser:users"); // doesn't currently work to allow clicking row
</script>

</h:form>
</f:view>
</html>
